##############################################################################
# Makefile for C++ Class Generator example.  Starting with a DTD (with dummy
# document), generates the classes (sample.h, sample.cpp), then builds the
# test program (CG from CG.cpp) which builds and validates a class.  Likewise
# AQ does the same sort of thing but using classes generated from a Schema.
##############################################################################

# include common definitions
include ../Makefile.defs

CLASSGEN=$(TOP)/bin/xmlcg

PROGS=	CG AQ

# Build programs
all: $(PROGS)

CG: smain.cpp sample.h sample.cpp
	$(CCC) -g -o CG $(INCLUDE) smain.cpp sample.cpp $(LIB)

AQ: qmain.cpp queue.h queue.cpp
	$(CCC) -g -o AQ $(INCLUDE) qmain.cpp queue.cpp $(LIB)

# Generate classes if needed
sample.h: sample.xml
	$(CLASSGEN) sample.xml

queue.h: queue.xsd
	$(CLASSGEN) -s queue queue.xsd

sure: $(PROGS)
	./CG
	@if cmp -s sample.out sample.std; then echo TEST_SUCCEEDED; else echo TEST_FAILED_DIFFERENCES_FOUND; fi
	./AQ
	@if cmp -s queue.out queue.std; then echo TEST_SUCCEEDED; else echo TEST_FAILED_DIFFERENCES_FOUND; fi

clean:
	rm -f sample.h sample.cpp sample.out
	rm -f queue.h queue.cpp queue.out
	rm -f *.o $(PROGS)
